package gframework.bean.progressPanel;

import gframework.bean.internalFrame.GInternalFrame;
import gframework.bean.mdiFrame.GMdiFrame;
import java.awt.Dimension;
import java.awt.Toolkit;

public class GProgressPanel extends GInternalFrame {

    private int maxValue = 0;

    public GProgressPanel(GMdiFrame i_mdiFrame) throws Exception {
        super(i_mdiFrame);
        initComponents();
        this.removeNotify();
        this.setBorder(null);
        this.setSize(250, 83);
        this.center();

        int w = mdiFrame.desktopPane.getSize().width;
        int h = mdiFrame.desktopPane.getSize().height;

        Dimension ds = Toolkit.getDefaultToolkit().getScreenSize();

        javax.swing.plaf.InternalFrameUI ifu = this.getUI();
        ((javax.swing.plaf.basic.BasicInternalFrameUI) ifu).setNorthPane(null);

        //this.setLocation(w - this.getSize().width, h - 83);
        this.setLocation(w - this.getSize().width, h - this.getSize().height);
    }

    public void setMensagem(String i_value) {
        lblMensagem.setText(i_value);
    }

    public int getMaxValue() {
        return maxValue;
    }

    public void setMaxValue(int MaxValue) {
        this.maxValue = MaxValue;
        pgrStatus.setMaximum(MaxValue);
    }

    public void setValue(int value) throws Exception {
        pgrStatus.setValue(value);
        lblMensagem.setText("Aguarde");

        if (value == maxValue) {
            this.setVisible(false);
        }
    }

    public int getValue() throws Exception {
        return pgrStatus.getValue();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblMensagem = new gframework.bean.label.GLabel();
        pgrStatus = new gframework.bean.progressBar.GProgressBar();
        gLabel2 = new gframework.bean.label.GLabel();

        setBorder(null);
        setPreferredSize(new java.awt.Dimension(250, 85));
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblMensagem.setText("lblMensagem");
        getContentPane().add(lblMensagem, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));
        getContentPane().add(pgrStatus, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 230, -1));

        gLabel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        getContentPane().add(gLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 250, 60));
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private gframework.bean.label.GLabel gLabel2;
    private gframework.bean.label.GLabel lblMensagem;
    private gframework.bean.progressBar.GProgressBar pgrStatus;
    // End of variables declaration//GEN-END:variables
}
